package com.zhangyu.shadow.ec.main.personal;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.zhangyu.shadow.core.delegate.bottom.BottomItemDelegate;
import com.zhangyu.shadow.ec.R;
import com.zhangyu.shadow.ec.R2;
import com.zhangyu.shadow.ec.main.personal.list.ListBean;
import com.zhangyu.shadow.ec.main.personal.list.ListItemType;
import com.zhangyu.shadow.ec.main.personal.list.ListMenuAdapter;
import com.zhangyu.shadow.ec.main.personal.order.OrderListDelegate;
import com.zhangyu.shadow.ec.main.personal.profile.UserProfileDelegate;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * @author zhangyu
 * @date 2017/12/4
 */

public class PersonalDelegate extends BottomItemDelegate {
    @BindView(R2.id.recycler_view)
    RecyclerView mRecyclerView;

    @Override
    public Object setLayout() {
        return R.layout.delegate_personal;
    }

    @Override
    public void onBindView(@Nullable Bundle savedInstanceState, View rootView) {

    }

    @OnClick(R2.id.tv_pre_pay)
    public void onPrePay() {
        getParentDelegate().start(OrderListDelegate.create(1));
    }
    @OnClick(R2.id.iv_user)
    public void onClickUserProfile(){
        getParentDelegate().start(new UserProfileDelegate());
    }
    @Override
    public void onLazyInitView(@Nullable Bundle savedInstanceState) {
        super.onLazyInitView(savedInstanceState);
        ListBean beanAddress = new ListBean.Builder().setName("收货地址")
                .setItemType(ListItemType.ITEM_NORMAL)
                .setUrl("{icon-address}")
                .build();
        ListBean beanSetting = new ListBean.Builder().setName("系统设置")
                .setUrl("{icon-setting}")
                .setItemType(ListItemType.ITEM_NORMAL)
                .build();
        List<ListBean> listBeen = new ArrayList<>();
        listBeen.add(beanAddress);
        listBeen.add(beanSetting);
        mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
        mRecyclerView.setAdapter(new ListMenuAdapter(listBeen));
    }
}
